<%@ page import="com.oval.util.JspHelper" %>
 <%--
 *  File:   LendSlipSummary.jsp
 *  Desc:	the Lend slip summary page
 *
 *  Date		    Author		    Changes
 *  2005-6-2	  andyyang		  Created
 *
 *  Copyright (C) 2000 - 2005 Oval Technologies, Inc.
 *  All rights reserved.
 *
 *  This software is the confidential and proprietary information of Oval
 *  Technologies, Inc. ("Confidential Information").  You shall not
 *  disclose such Confidential Information and shall use it only in
 *  accordance with the terms of the license agreement you entered into
 *  with Oval.
--%>
<%
  //init param
  String contextPath = request.getContextPath();
  StringBuffer resultSB = new StringBuffer();
%>
<%@ taglib uri="/WEB-INF/custom.tld" prefix="custom" %>
<%@ page language="java" %>     
<%@ page import="java.util.*" %>
<%@ page import="com.oval.foundation.view.OvalDispatchEngine"%>
<%
	if(request.getParameterValues("deleteKey")!=null)
	{
		String[] deleteKeys = request.getParameterValues("deleteKey");		
		for(int i=0; i<deleteKeys.length; i++)
		{
			OvalDispatchEngine.removeEndJobLock(deleteKeys[i],"");
			resultSB.append("remove the lock ["+deleteKeys[i]+"] successfully!<br>");
		}
	}
%>
<html>
<head>
<title>JobLockMgmt</title>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="<%=contextPath%>/css/cn/main.css" type="text/css">
<script language="JavaScript" src="<%=contextPath%>/css/cn/script.js"></script>
<script language="JavaScript" src="<%=contextPath%>/js/ScriptLib.js"></script>
<script language="JavaScript" >
function page_selectall(flag)
{
	if(flag)
		allCheck(document.all.deleteKey);
	else
		allCancel(document.all.deleteKey);		
}
function page_removelocks()
{
	//alert(frmToString(cform));
	cform.target="_self";
	cform.submit();
}
</script>

</head>

<body style="overflow: auto;">
<form name="cform" method="post" action="<%=contextPath%>/console/JobLockMgmt.jsp">

    <table width="100%" cellspacing="0" border="0" cellpadding="0">
      <tr>
				<td><b>Current Time:</b><%=JspHelper.filterNull( new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()))%></td>
      </tr>
      <tr>
        <td>
          <table width="100%" border="1" cellpadding="0" bordercolorlight="#999999" bordercolordark="#FFFFFF" cellspacing="0" align="center">
					<tr class="deepblue-left">
            <td width="22" class="title_center"><input type="checkbox" onclick="page_selectall(this.checked)" class="normalradio"></td>
            <td class="title_center">CREATED DATE</td>
            <td class="title_center">JOB NAME</td>
            <td class="title_center">USER ID</td>
          </tr>

<%
        Hashtable result = OvalDispatchEngine.jobHolder;        
        String key = null;
        Set keys = result.keySet();
        Iterator it = keys.iterator();
        int userid_len = 9;
        String jobName = "";
        String userID = "";
        while(it.hasNext())
        {
            key = (String) it.next();
            if(key.length()>userid_len)
            {
            	jobName = key.substring(0, key.length()-userid_len);
            	userID = key.substring(key.length()-userid_len);
            }else
            {
            	jobName = key.substring(0, key.length()-1);
            	userID = key.substring(key.length()-1);
            }
%>            
					<tr onMouseOver="this.className='tr-over'" onMouseOut="this.className='none'" class="none">
            <td>
              <input name="deleteKey" type="checkbox" value="<%=JspHelper.filterNull(key)%>" class="normalradio">
            </td>        
            <td><%=JspHelper.filterNull( new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format((java.sql.Date)result.get(key)))%></td>            
            <td><%=JspHelper.filterNull(jobName)%></td>
            <td><%=JspHelper.filterNull(userID)%></td>            
          </tr>
<%          
        }
%>            

          </table>
          <table width="100%" cellspacing="0" cellpadding="0">
            <tr><td class="summary_top"></td></tr>
            <tr>
              <td class="td_center">
                <a onclick="page_removelocks();"><input type="button" value="Unlock Selected Jobs" class="button1" border="0" ></a>
              </td>
            </tr>
          </table>
        </td>
      </tr>
      <tr>
      	<td>
      		<%out.println(resultSB);%>
      	</td>
      </tr>
    </table>
</form>
</body>
</html>
